//
//  FDHttpAPi.m
//  FD
//
//  Created by Yasin on 2018/10/13.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "FDHttpAPi.h"
#import "FDAuthorization.h" //POST请求签名和authorization
#import <AFNetworking.h>
#import "Reachability.h" //网络检测

#import "LoginViewController.h" //12-29

@implementation FDHttpAPi

#pragma mark  POST请求 + 工具方法

//https://github.com/facebook/SocketRocket
/**返回一个签名后的一个请求NSURLRequest*/
//+ (NSURLRequest *)rb_requestWithWithURL:(NSString *)urlStr
+ (NSURLRequest *)rb_requestWithUserOrderId:(NSString *)userOrderId
{
    //一 创建请求类,并设置请求头、请求体 就这样写 可用
    NSString *api = @"/websocket/position/subscribe";
    NSString *urlStr = [NSString stringWithFormat:@"%@%@?userOrderId=%@",kWSDomain,api,userOrderId];
    
    NSURL *url = [NSURL URLWithString:urlStr];
    
    FDLog(@"%@",url);
    
    NSMutableURLRequest *req  = [NSMutableURLRequest requestWithURL:url];
    
    req.timeoutInterval = 5;
    [req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    
    //时间戳 ：一定要传一样的。
    NSString *timeStampStr = [self getNowTime];
    
    //如果有token就传，没有就传空
    NSString *token = [self rb_token];

    //11-13url不参与签名
    NSString *autoStr = [FDAuthorization authorizationWithToken:token apiStr:api timeStamp:timeStampStr];
    
    // ❌❌❌❌❌❌❌❌❌巨坑 如果有换行符：❌❌❌❌❌❌❌❌❌ 是设置不了请求头的
    NSString *shouquanStr = [NSString pureStrWithOriginStr:autoStr]; //提纯
    [req setValue:shouquanStr forHTTPHeaderField:@"Authorization"];
    [req setValue:@"12345\n566" forHTTPHeaderField:@"test"]; //如果有换行,该请求头字段设置失败. 所以这句话谢了等于没写。
    
    [req setValue:@"1.0.0" forHTTPHeaderField:@"Authorization-Version"]; //版本
    [req setValue:timeStampStr forHTTPHeaderField:@"Authorization-Timestamp"]; //时间戳 需要和签名中的时间戳保持一致
    [req setValue:@"ios" forHTTPHeaderField:@"authorization-device"]; //设备
    NSString *language = NSLocalizedString(RequestLanguage, @"Accept-language");
    [req setValue:language forHTTPHeaderField:@"Accept-Language"]; //语言
    //返回一个请求
    return req;
}
/**根据urlstr返回一个返回一个设置了请求头的NSURLRequest对象*/
+ (NSURLRequest *)rb_URLRequestWithUrlAPI:(NSString *)api
{
    //一 创建请求类,并设置请求头、请求体 就这样写 可用
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",kWSDomain,api];
    NSURL *url = [NSURL URLWithString:urlStr];
    FDLog(@"%@",url);
    
    NSMutableURLRequest *req  = [NSMutableURLRequest requestWithURL:url];
    req.timeoutInterval = 5;
    
    //如果有token就传，没有就传空
    NSString *token = [self rb_token];
    //时间戳 ：一定要传一样的。
    NSString *timeStampStr = [self getNowTime];
    //11-13url不参与签名
    NSString *autoStr = [FDAuthorization authorizationWithToken:token apiStr:api timeStamp:timeStampStr];

    // ❌❌❌❌❌❌❌❌❌巨坑 如果有换行符：❌❌❌❌❌❌❌❌❌ 是设置不了请求头的
    NSString *shouquanStr = [NSString pureStrWithOriginStr:autoStr]; //提纯
    [req setValue:shouquanStr forHTTPHeaderField:@"Authorization"];
    [req setValue:timeStampStr forHTTPHeaderField:@"Authorization-Timestamp"]; //时间戳 需要和签名中的时间戳保持一致
//    [req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [req setValue:@"1.0.0" forHTTPHeaderField:@"Authorization-Version"]; //版本
    [req setValue:@"ios" forHTTPHeaderField:@"authorization-device"]; //设备
//    [req setValue:@"zh-CN" forHTTPHeaderField:@"Accept-Language"]; //语言
    //返回一个请求
    return req;
}


+ (void)rb_POSTWithAPI:(NSString *)api parDic:(NSDictionary *)parDic successBlock:(FDHttpSuccessBlock)success fialureBlcok:(FDHttpFailureBlock)failure {
    // 二 AFURLSessionManager
    AFURLSessionManager *manger = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    
    //创建一个请求NSURLReques
    NSMutableURLRequest *req = [self rb_NSURLRequestWithAPI:api parDic:parDic];
    req.timeoutInterval = 50; //2019-2-12设置请求超时
    
    [[manger dataTaskWithRequest:req completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
        
        // AFN获取响应头 https://www.jianshu.com/p/a9f09052eaed
        // NSHTTPURLResponse *httpRes = (NSHTTPURLResponse *)response;
        if (!error) {
            if (success) {
                success(responseObject);
                [self skipToLoginVCWithResponseDic:responseObject];
            }
        }else{
            if (failure) { failure(error); }
        }
        // 最后一定要启动,不然方法不走。
    }] resume];
}


+ (void)skipToLoginVCWithResponseDic:(NSDictionary *)responseObject {
          //12-29请求为授权强制跳转到登录页面
          NSString *event = responseObject[@"event"];
    if ([event isEqualToString:@"UNAUTHORIZED"]) {
        
        LoginViewController *loginVC = [[LoginViewController alloc] init];
        loginVC.isKickOffByUNAUTHORIZED = YES; //2019-2-25 标记是因为接口请求 event = UNAUTHORIZED 而被踢到登录页面
        UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:loginVC];
        [UIApplication sharedApplication].keyWindow.rootViewController = navVC;
    }
}

// 判断是否联网
+ (BOOL)isConnectNetWork{
    BOOL isExistenceNetwork = YES;
    Reachability *r = [Reachability reachabilityWithHostName:@"www.baidu.com"];
    switch ([r currentReachabilityStatus]) {
        case NotReachable:
            isExistenceNetwork=NO;
            FDLog(@"没有网络");
            break;
        case ReachableViaWWAN:
            isExistenceNetwork=YES;
            FDLog(@"正在使用3G网络");
            break;
        case ReachableViaWiFi:
            isExistenceNetwork=YES;
            FDLog(@"正在使用wifi网络");
            break;
    }
    return isExistenceNetwork;
}

/***返回一个设置了请求头、请求体，请求方法的请求*/
+ (NSMutableURLRequest *)rb_NSURLRequestWithAPI:(NSString *)api parDic:(NSDictionary *)parDic {
    //拼接url：域名 + api
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",kDomain,api];
    
    // 先将dic转JSON
    NSString *jsonStr = [self rb_jsonStrFromDic:parDic];
    
    //一 创建请求类,并设置请求头、请求体 就这样写 可用
    NSMutableURLRequest *req = [[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:urlStr parameters:nil error:nil];
    
    req.timeoutInterval = 5;
    [req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    
    //时间戳 ：一定要传一样的。
    NSString *timeStampStr = [self getNowTime];
    
    //如果有token就传，没有就传空
    NSString *token = [self rb_token];
    
    //登陆不能传token
    if ([api isEqualToString:AuthLogin]) token = nil;
    
    //    NSLog(@"11111:%@",token);
    
    NSString *autoStr = [FDAuthorization authorizationWithToken:token apiStr:api timeStamp:timeStampStr];
    
    // ❌❌❌❌❌❌❌❌❌巨坑 如果有换行符：❌❌❌❌❌❌❌❌❌ 是设置不了请求头的
    NSString *shouquanStr = [NSString pureStrWithOriginStr:autoStr]; //提纯
    
    //    NSString *test = @"NjAyYWVmNDM4OTc3NGJiZjljYjRhZGJiOWUxOTUz\nNTE6NWUwMDQwZDMxOGJhYTA0NTczYzc5YWI2NWMwZjdjODQyOTg5NmExNg==";
    
    [req setValue:shouquanStr forHTTPHeaderField:@"Authorization"];
    [req setValue:@"12345\n566" forHTTPHeaderField:@"test"]; //如果有换行,该请求头字段设置失败. 所以这句话谢了等于没写。
    
    [req setValue:@"1.0.0" forHTTPHeaderField:@"Authorization-Version"]; //版本
    [req setValue:timeStampStr forHTTPHeaderField:@"Authorization-Timestamp"]; //时间戳 需要和签名中的时间戳保持一致
    [req setValue:@"ios" forHTTPHeaderField:@"authorization-device"]; //设备
    
    NSString *language = NSLocalizedString(RequestLanguage, @"Accept-language");
    [req setValue:language forHTTPHeaderField:@"Accept-Language"]; //语言
    //    NSString *language = NSLocalizedString(RequestLanguage, @"zh-CN  en-US");
    //    FDLog(@"请求的语言是:%@",language);
    //    [req setValue:language forHTTPHeaderField:@"Accept-Language"];
    
    // 设置请求体: ⚠️❗️
    [req setHTTPBody:[jsonStr dataUsingEncoding:NSUTF8StringEncoding]];
    
    //    NSLog(@"所有的请求头:%@",[req allHTTPHeaderFields]);
    return req;
}


//!!!!: 1 生成十三位的时间戳
+ (NSString *)getNowTime{
    
    //获取当前时间戳
    NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];//获取当前时间0秒后的时间
    NSTimeInterval time=[date timeIntervalSince1970]*1000;// *1000 是精确到毫秒，不乘就是精确到秒
    NSString *timeSp = [NSString stringWithFormat:@"%.0f", time];
    
    return timeSp;
}

//!!!!:2 dic转json
+ (NSString *)rb_jsonStrFromDic:(NSDictionary *)dic{
    
    if (dic == nil) return nil;
    
    NSError *err;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&err];
    
    if (err) {
        NSLog(@"转JSON失败:%@",err);
        return nil;
    }
    
    NSString *jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//    NSLog(@"请求参数:%@",jsonStr);
    
    return jsonStr;
}


//!!!!:3 登陆成功 保存 token 到本地
+ (void)rb_saveToken:(NSString *)token {
    if ([NSString isEmptyString:token]) return;
 // @"token"
    [[NSUserDefaults standardUserDefaults] setValue:token forKey:TOKEN];
}
//返回token
+ (NSString *)rb_token {
    return [[NSUserDefaults standardUserDefaults] objectForKey:TOKEN];
}


#pragma mark - 接口
#pragma mark - 一 接口 auth 登陆注册相关模块
+ (void)requestRegisterWithParDic:(NSDictionary *)parDic successBlock:(FDHttpSuccessBlock)success failureBlock:(FDHttpFailureBlock)failure {
    NSString *api = AuthRegister;
    
    [self rb_POSTWithAPI:api parDic:parDic successBlock:^(id responseObjc) {
        
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        
        failure(error);
    }];
}

/**65 注册时获取邮箱验证码*/
+ (void)requestRegisterEmailVerifyCodeWithEmial:(NSString *)email successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure
{
    NSDictionary *parDic = @{@"email":email};
    [self rb_POSTWithAPI:AuthRegisterEmailVerification parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

+ (void)requestLoginWithParDic:(NSDictionary *)parDic successBlock:(FDHttpSuccessBlock)success failureBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:AuthLogin parDic:parDic successBlock:^(id responseObjc) {
        
        if ([responseObjc[@"event"] isEqualToString:@"SUCCESS"]) {
            NSString *token = responseObjc[@"data"][@"token"];
            //保存token
            [self rb_saveToken:token];
        }
        
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

//退出登录
+ (void)requestLogoutSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure
{
    [self rb_POSTWithAPI:AuthLogout parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
        
        [[NSUserDefaults standardUserDefaults] setValue:@"" forKey:TOKEN];
        
        FDLog(@"2019-1-1token:%@",[[NSUserDefaults standardUserDefaults] objectForKey:TOKEN]);
        
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**4.获取亚马逊云存储上传凭证*/
+ (void)requestAuthAmazonS3CloudStorageSuccessBlock:(FDHttpSuccessBlock)success failureBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:AuthAmazonCloudStorage parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

#pragma mark - 二 接口 首页
+ (void)requestHomeSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:Home parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
//        NSLog(@"首页数据:%@",[self rb_jsonStrFromDic:responseObjc]);
        
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
//商品详情
+ (void)requestGoodsDetailWithGoodsId:(NSNumber *)goodsId Block:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    
    //不能传字符串
    NSDictionary *parDic = @{@"id":goodsId};
    
    [self rb_POSTWithAPI:GoodsDetail parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**21、获取外送点餐首页数据 goodsClassifyId:主分类编号 */
+ (void)requestSYGoodsListWithGoodsClassifyId:(NSNumber *)goodsClassifyId SuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"goodsClassifyId":goodsClassifyId};
    [self rb_POSTWithAPI:SYGoodsList parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**27.添加到购物车(非套餐商品) 作废 */
+ (void)requestSYUserCartAddWithGoodId:(NSNumber *)goodsId quantity:(NSNumber *)quantity successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {

    if ([NSString isEmptyString:[NSString stringWithFormat:@"%@",goodsId]]) {
        return;
    }
    if ([NSString isEmptyString:[NSString stringWithFormat:@"%@",quantity]]) {
        return;
    }
    
    //请求参数
    NSDictionary *parDic = @{@"goodsId":goodsId,@"quantity":quantity};
    
    [self rb_POSTWithAPI:SYUserCartAdd parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**27-加入购物车*/
+ (void)requesSYUserCartAddWithParDic:(NSDictionary *)parDic successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:SYUserCartAdd parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/**29.购物车商品修改数量 {数量，购物车id}*/
+ (void)requestSYUserCartUpdateQuantity:(NSNumber *)quantity cartId:(NSNumber *)cartId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure{
    NSDictionary *parDic = @{@"id":cartId,@"quantity":quantity};
    
    [self rb_POSTWithAPI:SYUserCartUpdateQuantity parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**30.购物车移除商品 参数传{购物车id}*/
+ (void)requestSYUserCartRemoveCartId:(NSNumber *)cartId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"id":cartId};
    
    [self rb_POSTWithAPI:SYUserCartRemove parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/**31、获取购物车数据 和 获取外送点餐接口同时调用*/
+ (void)requestSYUserCartListSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    //传空zidan
    [self rb_POSTWithAPI:SYUserCartList parDic:@{} successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**37.获取优惠券列表*/
+ (void)requestSYCouponListSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:SYUserCouponList parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**38.可用的优惠券*/
+ (void)requestSYUserCouponUsableSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:SYUserCouponUsable parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**39.获取过期的优惠券列表*/
+ (void)requestSYUserCouponInvalidSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:SYUserCouponInvalid parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**首页-门店预约接口数据*/
+ (void)requestSYShopListSuccessBlock:(FDHttpSuccessBlock)success failureBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:SYShopList parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**获取店铺详情*/
+ (void)requestSYShopDetailId:(NSNumber *)shopId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure{
    NSDictionary *parDic = @{@"id":shopId};
    [self rb_POSTWithAPI:SYShopDetail parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}






#pragma mark - 三 接口 发现
+ (void)requestFindDataSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:Find parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


#pragma mark - 四 优惠券
/**领取优惠券*/
+ (void)requestObtainCouponWithId:(NSNumber *)couponId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    
    NSDictionary *parDic = @{@"id":couponId};
    
    [self rb_POSTWithAPI:UserCouponObtain parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

#pragma mark - 五 订单相关
/**44. 订单预览 外卖-底部-点击结算按钮调的接口*/
+ (void)requestDDOrderPreviewSuccessBlock:(FDHttpSuccessBlock)success failureBlock:(FDHttpFailureBlock)failBlock {
    [self rb_POSTWithAPI:DDUserOrderPreview parDic:@{} successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failBlock(error);
    }];
}
/**45.获取订单优惠券列表*/
+ (void)requestDDOrderCouponWithOrderAmount:(NSNumber *)orderAmount successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"orderAmount":orderAmount};
    [self rb_POSTWithAPI:DDUserOrderCoupon parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/***47 提交订单
 {
 "userCouponId": null,
 "userCartIdList": [648, 392],
 "userShippingAddressId": 15,
 "deliveryType": 0,
 "remark": ""
 }
 */
+ (void)requestDDOrderSumitParDic:(NSDictionary *)parDic successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:DDUserOrderSubmit parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/**
48 获取订单列表 @param deliveryType 0:外卖 1:自提
 当delievryType :0 时
 不传改字段： 全部数据 传 nil；传空数组服务器会返回“系统繁忙”
 [0]待付款； [4] 待评价  [6,7]退款售后
 */
+ (void)requestDDOrderListWithDeliveryType:(NSNumber *)deliveryType status:(NSArray *)status successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure{
    //请求体
    NSMutableDictionary *parDic = [NSMutableDictionary dictionary];
    [parDic setValue:deliveryType forKey:@"deliveryType"];//送餐方式 0:外卖 1:自提
    
    if (status == nil) { //获取全部数据 不传 status字段
        
    }else {
        [parDic setValue:status forKey:@"status"];
    }
    
    FDLog(@"订单接口请求参数:%@",parDic);
    
    
    [self rb_POSTWithAPI:DDUserOrderList parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**51. 获取门店预约接口数据 这里有坑 必须传 空字典 {}*/
+ (void)requestDDShopReservationSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
//    这里有坑:必须传 @{} 才能请求到数据
    [self rb_POSTWithAPI:DDUserShopReservationList parDic:@{} successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**50.用户预约*/
+ (void)requestUserLiJiYuyuePardic:(NSDictionary *)parDic successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserLiJiYuYue parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**52.获取预约门店信息*/
+ (void)requestUserYuYueShopMesssageWithYuYueId:(NSNumber *)yuyueId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"id":yuyueId};
    
    [self rb_POSTWithAPI:UserYuYueShopDetailMessage parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**53.预约订单详情*/
+ (void)requestUserYuYueOrderDetailWithUserOrderId:(NSString *)userOrderId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure
{
    NSDictionary *parDic = @{@"userOrderId":userOrderId};
    [self rb_POSTWithAPI:UserYuYueOrderDetail parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

#pragma mark - 我的页面
+ (void)requestUserMySuccessBlock:(FDHttpSuccessBlock)sucess failBlock:(FDHttpFailureBlock)failure {

    [self rb_POSTWithAPI:UserMy parDic:nil successBlock:^(id responseObjc) {
        sucess(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**意见反馈接口*/
+ (void)requestUserFadebackWithContent:(NSString *)content successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    
    //空字段直接返回
    if ([NSString isEmptyString:content]) return;
    
    NSDictionary *parDic = @{@"content":content};
    [self rb_POSTWithAPI:UserMyFadeBack parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**5、修改昵称*/
+ (void)requestUserUpdateNickname:(NSString *)nickname successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure
{
    if([NSString isEmptyString:nickname]) {
        [JRToast showWithText:NSLocalizedString(ToastNickNameCannotKong, @"昵称不能为空")];
        return;
    }
    
    NSDictionary *pardic = @{@"nickname":nickname};
    [self rb_POSTWithAPI:UserUpdateNickname parDic:pardic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**6.修改头像接口*/
+ (void)requestUserUpdateTouXiangStr:(NSString *)headName successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure
{
    NSDictionary *parDic = @{@"head":headName};
    [self rb_POSTWithAPI:UserUpdateHead parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**7.修改手机号*/
+ (void)requestUserUpdatePhone:(NSString *)phone successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    if ([NSString isEmptyString:phone]) {
        [JRToast showWithText:NSLocalizedString(ToastPhoneCannotKong, @"手机号不能为空")];
        return;
    }
    
    NSDictionary *parDic = @{@"phone":phone};
    [self rb_POSTWithAPI:UserUpdatePhone parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/***8.修改性别 0：男 1：女*/
+ (void)requestUserUpdateSex:(NSNumber *)sex successBlock:(FDHttpSuccessBlock)success fialBlock:(FDHttpFailureBlock)failure {

    NSDictionary *parDic = @{@"sex":sex};
    [self rb_POSTWithAPI:UserUpdateSex parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**9.修改生日 请传13位的时间戳 NSNumser */
+ (void)requestUserUpdateBirthday:(NSNumber *)birthday successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    if ([NSString isEmptyString:[NSString stringWithFormat:@"%@",birthday]]) {
        [JRToast showWithText:NSLocalizedString(ToastBirthdayCannotKong, @"生日不能为空")];
        return;
    }
    
    NSDictionary *parDic = @{@"birthday":birthday};
    
    [self rb_POSTWithAPI:UserUpdateBirthday parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/**10。个人信息接口*/
+ (void)requestUserPersonMsgSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserPersonalProfile parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**11、获取用户的偏好标签*/
+ (void)requestUserLabelListSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserLabelList parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**12.获取所有标签列表*/
+ (void)requestUserLabelOptionListSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserLabelOptionList parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/***13.保存标签*/
+ (void)requestUserLabelSaveTagId:(NSNumber *)tagId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"id":tagId};
    [self rb_POSTWithAPI:UserLabelSave parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/***14.删除标签*/
+ (void)requestUserLabelRemoveTagId:(NSNumber *)tagId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"id":tagId};

    [self rb_POSTWithAPI:UserLabelRemove parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/** 17.新增家庭成员 @param name 姓名  @param timeStamp 13位的时间戳 下同 */
+ (void)requestUserFamilSaveName:(NSString *)name birthdaystamp:(NSNumber *)timeStamp successBlock:(FDHttpSuccessBlock)succcess failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"memberName":name,@"memberBirthday":timeStamp};
    
    [self rb_POSTWithAPI:UserFamilySave parDic:parDic successBlock:^(id responseObjc) {
        succcess(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**18.编辑家庭成员信息*/
+ (void)requestUserFamilUpdateName:(NSString *)memberName birthdaystamp:(NSNumber *)timestamp memberId:(NSNumber *)memberid successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {

    NSDictionary *parDic = @{@"memberName":memberName,
                             @"memberBirthday":timestamp,
                             @"id":memberid};
    [self rb_POSTWithAPI:UserFamilyUpdate parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
        
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/**19.获取家庭成员列表*/
+ (void)requestUserFamilListSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserFamilyList parDic:@{} successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**20.移除家庭成员信息*/
+ (void)requestUserFamilRemoveMemberId:(NSNumber *)memberId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"id":memberId};
    [self rb_POSTWithAPI:UserFamilyRemove parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**40.新增收货地址 参数较多，直接传一个大字典算了
 2019-1-7 第一个region，修改后， 你给我传空字符串"" 或者 null就行
 下面的 zipCode houseNumber 分别表示邮政编码与门牌号码
 */
+ (void)requestUserAddressAddressAddWithParDic:(NSDictionary *)dic successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserShippingAddressSave parDic:dic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**41-编辑收货地址*/
+ (void)requestUserAddressEditWithParDic:(NSDictionary *)dic successBlock:(FDHttpSuccessBlock)succes failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserShippingAddressUpdate parDic:dic successBlock:^(id responseObjc) {
        succes(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**40-1调用googleAP将文字地址-->坐标
 请求参数：https://maps.googleapis.com/maps/api/geocode/json?address=【替换为detail字段的详细地址】&components=country:IE&key=【替换为接口请求密钥】
 
 请求示例：https://maps.googleapis.com/maps/api/geocode/json?address=3%20Kenley%20ave&components=country:IE&key=AIzaSyCNRNJ_-QLQ-Bh1mVHqFV-82tZsYvfI4cs
  */
+ (void)requestGoogleAPISGetGeometryWithAddress:(NSString *)address successBlock:(RBSuccessBlock)success failBlock:(RBFailureBlock)failure {
    NSString *googlesMapAPI = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/geocode/json?address=%@&components=country:IE&key=%@",address,kGoogleMapAPIKey];
    
    //NSLocalizedDescription=不支持的 URL
    googlesMapAPI = [googlesMapAPI stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    
    FDLog(@"接口url:%@",googlesMapAPI);
    
    [RBNetWorkTool rb_getWithUrl:googlesMapAPI parDic:nil successH:^(NSDictionary *responObjc) {
//        success(responObjc);
        
        //回调经纬度
        NSArray *results = responObjc[@"results"];
        if (results.count) {
            NSDictionary *dic = [results firstObject];
            NSDictionary *locationDic = dic[@"geometry"][@"location"];
            success(locationDic);
        }
    } failH:^(NSError *error) {
        failure(error);
    }];
}
/**40-2调用googleAPI地理反编码.将经纬度转换为地名
 https://maps.googleapis.com/maps/api/geocode/json?latlng=51.900270,-8.557940&key=AIzaSyDU8SBtzx84CB2gf2kfZhC_Y9BRP6U7znw
 */
+ (void)requestGoogleAPIReverseGeocodeUrl:(NSString *)urlStr successBlock:(void (^)(NSString *))success failBlock:(RBFailureBlock)failure {
    
    //NSLocalizedDescription=不支持的 URL
    urlStr = [urlStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    [RBNetWorkTool rb_getWithUrl:urlStr parDic:nil successH:^(NSDictionary *responObjc) {
        NSArray *results = responObjc[@"results"];
        NSDictionary *dic = [results firstObject];
        NSString *address = dic[@"formatted_address"];
        success(address);
    } failH:^(NSError *error) {
        failure(error);
    }];
}


//+ (void)requestGoogleAPISGetGeometryWithAddress:(NSString *)address successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
//
////    请求参数：https://maps.googleapis.com/maps/api/geocode/json?address=【替换为detail字段的详细地址】&components=country:IE&key=【替换为接口请求密钥】
//    NSString *googlesAPI = @"https://maps.googleapis.com/maps/api/geocode/json?";
//
//    NSDictionary *pardic = @{@"address":address,@"components":@"country:IE",@"key":kGoogleMapAPIKey};
////    NSString *resultUrl = [NSString stringWithFormat:@"%@%@&components=country:IE&key=%@",googlesAPI,address,kGoogleMapAPIKey];
//
//    AFHTTPSessionManager *aManager = [AFHTTPSessionManager manager];
////    aManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/xml",@"text/json",@"text/plain",@"text/JavaScript",@"application/json",@"image/jpeg",@"image/png",@"application/octet-stream",nil];
//    aManager.responseSerializer = [AFHTTPResponseSerializer serializer];
//    // 设置超时时间
//    aManager.requestSerializer.timeoutInterval = 5;
//
//    [aManager GET:googlesAPI parameters:pardic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        success((NSDictionary *)responseObject);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failure(error);
//    }];
//}

//42.删除收货地址
+ (void)requestUserAddressRemoveWithID:(NSNumber *)addressId succesBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"id":addressId};
    
    [self rb_POSTWithAPI:UserShippingAddrssRemove parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

//43.获取 收货地址列表
+ (void)requestUserShouHuoAddressSucccessBlock:(FDHttpSuccessBlock)success fialBlock:(FDHttpFailureBlock)failure {
    
    [self rb_POSTWithAPI:UserShipingAddressList parDic:@{} successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**49.订单详情 */
+ (void)requestUserOrderDetailOrderId:(NSString *)orderId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure
{
    NSDictionary *parDic = @{@"id":orderId};
    
    [self rb_POSTWithAPI:UserOrderDetail parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
        //错误提示
        FDLog(@"%@",[error localizedDescription]);
    }];
}

/**55.查询订单订单状态
 前提条件根据这个接口 /user/order/detail 返回的 status字段做判断
 status    0 不处理     忽略
 [1,2,3,4]  本接口固定传一个数组[@1,@2,@3,@4] (已下单、制作中、派送中、已完成)
 对应的代付款、待评价订单详情
 
 [6,7,8]    本接口固定传一个数组[@6,@7,@8] (取消订单、退款中,退款成功)
 对应退款、售后订单详情
 ========================
 */
+ (void)requestUserOrderStatusWithOrderId:(NSString *)orderId Status:(NSArray<NSNumber *> *)status successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure
{
    NSDictionary *parDic = @{@"userOrderId":orderId,@"status":status};
    [self rb_POSTWithAPI:UserOrderState parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**56.评价订单*/
+ (void)requestUserEvaluteOrederWithParDic:(NSDictionary *)parDic successBlock:(FDHttpSuccessBlock)success fialBlock:(FDHttpFailureBlock)failure {
    
    [self rb_POSTWithAPI:UserEvaluateOrder parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**57.门店订单评价列表接口*/
+ (void)requestUserShopOrderEvaluateListWithShopId:(NSNumber *)shopId successBlock:(FDHttpSuccessBlock)success fialBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"id":shopId};
    [self rb_POSTWithAPI:UserShopOrderEvaluateList parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**57.积分明细*/
+ (void)requestJiFenMingXiSuccessBlock:(FDHttpSuccessBlock)success fialBlock:(FDHttpFailureBlock)failure
{
    [self rb_POSTWithAPI:UserJiFenMingXi parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**58.获取亚马逊云存储上传多张图片名字*/
+ (void)requestAWSS3MultipleWithQuantity:(NSInteger)quantity successBlock:(FDHttpSuccessBlock)success fialBlock:(FDHttpFailureBlock)failure {
    if (quantity<1) {
        quantity = 1;
    }
    NSDictionary *parDic = @{@"quantity":@(quantity)};
    [self rb_POSTWithAPI:UserAuthAwsAtsS3PutMultiple parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/**59 获取商家配送范围,超出配送范围时调用此接口 */
+ (void)requestUserShopRangListSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserShopRangeList parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**60.客服电话*/
+ (void)requestKeFuDianHuaSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:Home_KeFuDianHua parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**61.营业时间*/
+ (void)requestYinGYeShiJianSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:Home_YingYeShiJian parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/**62.判断用户坐标点是否在配送范围, 超出配送范围时调用此接口
 */
+ (void)requestUserShopInRnageWithLongitude:(NSNumber *)longitude latitude:(NSNumber *)latitude successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {

    NSDictionary *parDic = @{@"latitude":latitude,@"longitude":longitude};
    
    [self rb_POSTWithAPI:UserShopInRange parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**66.找回密码发送验证码*/
+ (void)requestUserFindPWdSendCodeWithEmail:(NSString *)email successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"email":email};
    [self rb_POSTWithAPI:UserForgetpwdSendVerifyCode parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**67.找回密码*/
+ (void)requestChangePwdPardic:(NSDictionary *)parDic successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure
{
    [self rb_POSTWithAPI:UserChangePwd parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/***69.获取订单支付链接*/
+ (void)requestUserOrderPaymentUrlWithOrderId:(NSString *)userOrderId successBlock:(FDHttpSuccessBlock)success fialBlock:(FDHttpFailureBlock)failure {
    
    NSDictionary *parDic = @{@"userOrderId":userOrderId};
    
    [self rb_POSTWithAPI:UserOrderPaymentUrl parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**70.修改密码*/
+ (void)requestUserUpdatePasswordJiuPwd:(NSString *)jiupwd xinstr:(NSString *)xin surePWd:(NSString *)surepwd scucessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    
    
    //服务器爱判断就让服务器判断
    NSDictionary *parDic = @{@"oldPassword":([NSString isEmptyString:jiupwd] ? @"" : jiupwd),
                             @"newPassword":([NSString isEmptyString:xin] ? @"": xin),
                             @"againNewPassword":([NSString isEmptyString:surepwd] ? @"" : surepwd)
                             };
    
    [self rb_POSTWithAPI:UserUpdatePassword parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/**72.首页查看配送范围*/
+ (void)requestHomeShopRanageListV2SuccessBlock:(FDHttpSuccessBlock)success failureBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserShopRangeListV2 parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**
 73.获取运费
 
 @param userShippingAddressId 用户收货地址编号
 */
+ (void)requestFreightWithUserShippingAddressId:(NSNumber *)userShippingAddressId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {

    NSDictionary *parDic = @{@"userShippingAddressId":userShippingAddressId};
    
    [self rb_POSTWithAPI:UserOrderFreightPrice parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**75.再来一单 订单预览*/
+ (void)requestZaiLaiYiDanPreviewWithUserOrderId:(NSString *)orderId successBlock:(FDHttpSuccessBlock)success failureBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parDic = @{@"userOrderId":orderId};
    [self rb_POSTWithAPI:UserOrderPreviewAgain parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**76.再来一单 确认订单*/
+ (void)requestZaiLaiYiDanSubmitWithParamDic:(NSDictionary *)parDic successBlock:(FDHttpSuccessBlock)success failureBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserOrderSubmitAgain parDic:parDic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
/**77.加载商品介绍模板文本*/
+ (void)requestGoodsDetailDescribeTemplateSuccessBlock:(FDHttpSuccessBlock)success failureBlock:(FDHttpFailureBlock)failure {
    [self rb_POSTWithAPI:UserGoodsDetailIntroduceTemplate parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**2018-12-30加载首页轮播图模板*/
+ (void)requestHomeWhirligigTempleateSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {

    [self rb_POSTWithAPI:HomeWhirligigTemplate parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**12-31请求商品列表轮播图列表*/
+ (void)requestGoodsListWhirligigSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
 
    [self rb_POSTWithAPI:UserGoodsListWhirligigAPI parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


#pragma mark - 七11-19 接口修改
/**修改:商品类目*/
+ (void)requestShangPinNeiMuSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {

    //不要参数也要传 @{}，不然报错：消息不可读
    [self rb_POSTWithAPI:UserGoodsClassifyListFirst parDic:@{} successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/**79.获取订单详情--骑手信息
 调用时机： 条件改一下，订单配送方式为外送(delivery_type=0) 并且订单状态不等于0、1、2
 */
+ (void)requestOrderDetailRiderMessageWithOrderId:(NSString *)orderId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *pardic = @{@"id":orderId};
    [self rb_POSTWithAPI:UserOrderDetailRider parDic:pardic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**84 获取消息推送模板*/
+ (void)requestHtmlTemplatePushSuccessBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    
    [self rb_POSTWithAPI:HtmlTemplatePush parDic:nil successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}


/**87.线上支付*/
+ (void)requestPayOnlineWithOrderId:(NSString *)orderId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    
    NSDictionary *pardic = @{@"userOrderId":orderId};
    [self rb_POSTWithAPI:UserOrderPaymentOnline parDic:pardic successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}

/**88.线下支付*/
+ (void)requestPayOfflineWithOrderId:(NSString *)orderId successBlock:(FDHttpSuccessBlock)success failBlock:(FDHttpFailureBlock)failure {
    NSDictionary *parm = @{@"userOrderId":orderId};
    
    [self rb_POSTWithAPI:UserOrderPaymentOffline parDic:parm successBlock:^(id responseObjc) {
        success(responseObjc);
    } fialureBlcok:^(NSError *error) {
        failure(error);
    }];
}
@end
